home *** CD-ROM | disk | FTP | other *** search
/ Champak 48 / cdrom_image.iso / Games / rollerrush / game.dcr / cars_9_game frame.ls < prev    next >
Encoding:
Text File  |  2007-10-01  |  5.3 KB  |  218 lines

  1. property pDid25, pDid35, pDid45, sTime, pDoneLevel, pNextSurvivalTime, pSurvivalCarAdded, pLastSurvivalTime, pGameOverTime, pCarsPlayed
  2. global UsedCars, RemoveCars, UnUsedCars, gWantToAddNow, CarsInLine, gWaitPoints, gCarList, gPaused, gLevel, gDoingTutorial, gSurvivalLives, gTimePlayed
  3.  
  4. on beginSprite me
  5.   sTime = the milliSeconds
  6.   pDid25 = 0
  7.   pDid35 = 0
  8.   pDid45 = 0
  9.   pDoneLevel = 0
  10.   pNextSurvivalTime = 1
  11.   pSurvivalCarAdded = 0
  12.   pLastSurvivalTime = 0
  13.   pGameOverTime = 0
  14.   pCarsPlayed = 0
  15. end
  16.  
  17. on prepareFrame me
  18.   if gPaused then
  19.     return 
  20.   end if
  21.   if (the milliSeconds - sTime) > 1000 then
  22.     AddSecond()
  23.     sTime = the milliSeconds
  24.     if gLevel = 42 then
  25.       if GetTime() = 150 then
  26.         sprite(107).visible = 1
  27.       else
  28.         if GetTime() = 300 then
  29.           sprite(105).visible = 1
  30.           sprite(34).visible = 1
  31.         end if
  32.       end if
  33.     end if
  34.   end if
  35.   if gLevel < 42 then
  36.     UpdateRegularGame()
  37.   else
  38.     UpdateSurvivalGame()
  39.   end if
  40.   sendSprite(3, #update)
  41.   sendSprite(4, #update)
  42.   sendSprite(6, #update)
  43.   sendSprite(5, #update)
  44.   sendSprite(110, #update)
  45.   if (gLevel > 30) and (gLevel < 42) then
  46.     sendSprite(115, #update)
  47.   end if
  48.   if sprite(675).visible then
  49.     sendSprite(675, #update)
  50.   end if
  51.   g = UsedCars.count
  52.   repeat with b = 1 to g
  53.     sendSprite(UsedCars[b], #update)
  54.   end repeat
  55.   g = RemoveCars.count
  56.   repeat with b = 1 to g
  57.     deleteOne(UsedCars, RemoveCars[b])
  58.   end repeat
  59.   RemoveCars = []
  60. end
  61.  
  62. on exitFrame me
  63.   global gScore, gLevel
  64.   if (pDoneLevel = 1) and (GetTime() >= pGameOverTime) then
  65.     if gLevel > 0 then
  66.       CheckHighScore(gLevel, gScore)
  67.     else
  68.       sleep(2)
  69.     end if
  70.     go("Over")
  71.   else
  72.     go(the frame)
  73.   end if
  74. end
  75.  
  76. on UpdateRegularGame me
  77.   c = gCarList.count
  78.   repeat with b = 1 to c
  79.     if gCarList[b].inPlay = 0 then
  80.       if (gTimePlayed >= gCarList[b].time) and (gWaitPoints.count > CarsInLine.count) then
  81.         if gDoingTutorial and (b = 1) then
  82.           sendSprite(836, #show, 2)
  83.         end if
  84.         pCarsPlayed = pCarsPlayed + 1
  85.         sendSprite(701, #update, gCarList.count, pCarsPlayed)
  86.         gCarList[b].inPlay = 1
  87.         numpeeps = gCarList[b].number
  88.         cols = []
  89.         repeat with h = 1 to numpeeps
  90.           if gCarList[b].color.char[h] = "R" then
  91.             append(cols, 1)
  92.             next repeat
  93.           end if
  94.           if gCarList[b].color.char[h] = "B" then
  95.             append(cols, 2)
  96.             next repeat
  97.           end if
  98.           if gCarList[b].color.char[h] = "G" then
  99.             append(cols, 3)
  100.             next repeat
  101.           end if
  102.           if gCarList[b].color.char[h] = "Y" then
  103.             append(cols, 4)
  104.             next repeat
  105.           end if
  106.           if gCarList[b].color.char[h] = "P" then
  107.             append(cols, 5)
  108.           end if
  109.         end repeat
  110.         carType = 0
  111.         if gCarList[b].type = "Girl" then
  112.           carType = 1
  113.         else
  114.           if gCarList[b].type = "Senior" then
  115.             carType = 2
  116.           else
  117.             if gCarList[b].type = "Man" then
  118.               carType = 3
  119.             else
  120.               if gCarList[b].type = "Woman" then
  121.                 carType = 4
  122.               else
  123.                 if gCarList[b].type = "Boy" then
  124.                   carType = 5
  125.                 end if
  126.               end if
  127.             end if
  128.           end if
  129.         end if
  130.         if numpeeps <= 2 then
  131.           carSize = 1
  132.         else
  133.           if numpeeps <= 4 then
  134.             carSize = 2
  135.           else
  136.             carSize = 3
  137.           end if
  138.         end if
  139.         sendSprite(UnUsedCars[1], #GetInLine, numpeeps, carType, cols, carSize)
  140.         exit repeat
  141.       end if
  142.     end if
  143.   end repeat
  144.   if (CarsInLine.count = 0) and (gCarList[gCarList.count].inPlay = 1) then
  145.     pDoneLevel = 1
  146.     repeat with b = 15 to 18
  147.       dl = sendSprite(b, #GetEmpty)
  148.       if dl = 0 then
  149.         pDoneLevel = 0
  150.         exit repeat
  151.       end if
  152.     end repeat
  153.     if pDoneLevel = 1 then
  154.       stuff = sendSprite(110, #GarbageCheck)
  155.       if (stuff[1] = "trash") or (stuff[2] = "trash") then
  156.         pDoneLevel = 0
  157.       end if
  158.     end if
  159.     if pDoneLevel then
  160.       if pGameOverTime = 0 then
  161.         pGameOverTime = GetTime() + 2
  162.       end if
  163.     end if
  164.   end if
  165. end
  166.  
  167. on UpdateSurvivalGame me
  168.   if GetTime() = pNextSurvivalTime then
  169.     t = GetTime()
  170.     adj = 15 - (t / 60)
  171.     if adj < 5 then
  172.       adj = 5
  173.     end if
  174.     pNextSurvivalTime = pNextSurvivalTime + adj
  175.     if t < 90 then
  176.       peepList = [2]
  177.     else
  178.       if t < 180 then
  179.         peepList = [2, 1]
  180.       else
  181.         if t < 270 then
  182.           peepList = [2, 1, 3]
  183.         else
  184.           if t < 360 then
  185.             peepList = [2, 1, 3, 5]
  186.           else
  187.             peepList = [2, 1, 3, 4, 5]
  188.           end if
  189.         end if
  190.       end if
  191.     end if
  192.     numpeeps = random(6)
  193.     cols = []
  194.     repeat with b = 1 to numpeeps
  195.       c = random(5)
  196.       append(cols, c)
  197.     end repeat
  198.     r = random(peepList.count)
  199.     carType = peepList[r]
  200.     if numpeeps <= 2 then
  201.       carSize = 1
  202.     else
  203.       if numpeeps <= 4 then
  204.         carSize = 2
  205.       else
  206.         carSize = 3
  207.       end if
  208.     end if
  209.     if gWaitPoints.count > CarsInLine.count then
  210.       sendSprite(UnUsedCars[1], #GetInLine, numpeeps, carType, cols, carSize)
  211.     end if
  212.   end if
  213.   if gSurvivalLives = 0 then
  214.     pGameOverTime = GetTime()
  215.     pDoneLevel = 1
  216.   end if
  217. end
  218.